package com.itheima.clientAndService01;

import java.util.ArrayList;
import java.util.stream.Stream;

public class ArgsClass05 {

    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三，11");
        list.add("李四，222");
        list.add("王五，3333");
        list.add("赵六，44444");
        list.add("钱七，555555");

        //method1(list);
        //sortMethod(list);
        //method2(list);

    }

    private static void sortMethod(ArrayList<String> list) {
        list.stream().sorted((s1,s2) -> {
            int num1 = s1.length() - s2.length();
            int num2 = num1 == 0 ? s1.compareTo(s2) : num1;
            return num1;
        }).forEach(s -> System.out.println(s));
    }

    private static void method1(ArrayList<String> list) {
        list.stream().limit(2).forEach(s -> System.out.println(s));
        System.out.println("----------------------------");
        list.stream().skip(2).forEach(s -> System.out.println(s));
        System.out.println("----------------------------");
        ArrayList<String> list1 = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ddd");
        Stream<String> stream1 = list.stream();
        Stream<String> stream2 = list1.stream();
        Stream.concat(stream1,stream2).forEach(s -> System.out.println(s));
        System.out.println("----------------------------");
        list.stream().distinct().forEach(s -> System.out.println(s));
        System.out.println("----------------------------");
        list.stream().filter(s -> s.startsWith("a")).forEach(s -> System.out.println(s));
    }
}
